package request

import (
	"ahutoj/web/dao"
	"ahutoj/web/io/constanct"
)

type User struct {
	UID     string `json:"UID" binding:"required"`
	Uname   string `json:"UserName" binding:"required"`
	Pass    string `json:"Pass"`
	School  string `json:"School"`
	Classes string `json:"Classes"`
	Major   string `json:"Major"`
	QQ	    string `json:"QQ"`
	Signature     string `json:"Signature"`
	Year 		  string `json:"Year"`
	Vjid    string `json:"Vjid"`
	Email   string `json:"Email"`
}
type UserInfoReq struct {
	UID string `json:"uid" binding:"required"`
}
type UserEditReq struct {
	Uname   string `json:"UserName"`
	School  string `json:"School"`
	Classes string `json:"Classes"`
	Major   string `json:"Major"`
	QQ	    string `json:"QQ"`
	Signature     string `json:"Signature"`
	Year 		  string `json:"Year"`
	Vjid    string `json:"Vjid"`
	Vjpwd   string `json:"Vjpwd"`
	Email   string `json:"Email"`
}

type UserEditPassReq struct {
	Pwd    string `json:"Pwd" binding:"required"`
	OldPwd string `json:"OldPwd" binding:"required"`
}
type UserEditHeadImageReq struct {
	HeadPath    string `json:"HeadPath" binding:"required"`
}
type UserEditVjudgeReq struct {
	Vjid  string `json:"Vjid"`
	Vjpwd string `json:"Vjpwd"`
}

type AddUsersRangeReq struct {
	Number   int     `json:"Number"`
	Prefix   string  `json:"Prefix"`
	School   string  `json:"School"`
	Password *string `json:"Password"`
}
type AddUserItem struct {
	UID      string `json:"UID"`
	UserName string `json:"UserName"`
	Pass     string `json:"Pass"`
}
type AddUsersReq []AddUserItem

type GetUsersReq struct{
	GetListReq
	Token string `query:"Token"`
}

type UserStatusInfoReq struct {
	UID    string               `json:"UID"`
	Type   constanct.StatusTime `json:"Type"`
	Time   int                  `json:"Time"`
	Result constanct.OJResult   `json:"Result"`
}

type GetUserSolutionListReq struct {
	GetListReq
	UID string `query:"UID"`
}

func (u UserEditReq) ToUser(uid string) *dao.User {
	return &dao.User{
		UID:     uid,
		Uname:   u.Uname,
		School:  u.School,
		Classes: u.Classes,
		Major:   u.Major,
		Email:   u.Email,
		Year:    u.Year,
		Signature: u.Signature,
	}
}

func (u UserEditVjudgeReq) ToUser(UID string) *dao.User {
	return &dao.User{
		UID:   UID,
		Vjid:  u.Vjid,
	}
}

type CodeForceBindReq struct {
	CodeForceUser string `json:"CodeForceUser"`
	CodeForcePass string `json:"CodeForcePass"`
}

type AtcoderBindReq struct {
	AtcoderUser   string `json:"AtcoderUser"`
	AtcoderPass   string `json:"AtcoderPass"`    
}

type NowcoderBindReq struct {
	NowcoderUser  string `json:"NowcoderUser"`
	NowcoderPass string `json:"NowcoderPass"`
}

type PasswordForgetReq struct {
	Email string `json:"Email"`
	NewPassword string `json:"NewPassword"`
}

type AdminChangeUserReq struct {
	UID      string `json:"UID,omitempty"`
	Password string `json:"Password,omitempty"`
	Email   string  `json:"Email,omitempty"`
}

type VerifyEmailReq struct {
	Email string 		 `json:"Email"`
	Uname string		 `json:"Uname,omitempty"`
	Method EmailMethod 	 `json:"Method"`
	Type   EmailType 	 `json:"Type"`
}

type CodeVerifyReq struct {
	UID   string 		`json:"UID,omitempty"`
	Email string 		`json:"Email,omitempty"`
	Code  string  		`json:"Code"`
	Type   EmailType 	`json:"Type"`
}

type EmailChangeReq struct {
	Email string `json:"Email"`
}

type QQInfoReq struct{
	Code string `query:"Code"`
	State string `query:"State"`
}

type QQLoginReq QQInfoReq

type QQBindReq  QQInfoReq

type EmailMethod uint8
const(
	Link     EmailMethod = 0//链接
	Code    EmailMethod = 1//验证码
)

type EmailType uint8
const(
	Register     EmailType = 0//注册
	ForgetPass   EmailType = 1//忘记密码
	Login        EmailType = 2//登录
	ChangeEmail  EmailType = 3//修改邮箱
)


type AddGroupReq struct {
    GroupName string `json:"GroupName"`
	GroupTask  string `json:"GroupTask"`
}

type DeleteGroupReq struct {
    GID int64 `json:"GID"`
}

type EditGroupReq struct {
    GID        int64  `json:"GID"`
    GroupName  string `json:"GroupName"`
    GroupTask  string `json:"GroupTask"`
}

type GroupTransferReq struct {
    GID int64  `json:"GID"`
    UID string `json:"UID"`
}

type AddUserToGroupReq struct {
    GID int64  `json:"GID"`
    UID string `json:"UID"`
}

type DeleteUserFromGroupReq struct {
    GID int64  `json:"GID"`
    UID string `json:"UID"`
}

type JoinGroupReq struct {
    InviteCode string `json:"InviteCode"`
}

type QuitGroupReq struct {
    GID int64  `json:"GID"`
}

type GetGroupTraceReq struct {
    UIDs []string `json:"UIDs"`
	GID int64 
}

